home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / MPW Interfaces & Libraries / PInterfaces / ErrMgr.p < prev    next >
Encoding:
Text File  |  1992-01-29  |  4.0 KB  |  109 lines  |  [TEXT/MPS ]

  1. {
  2. Created: Tuesday, August 2, 1988 at 12:26 PM
  3.     ErrMgr.p
  4.     Pascal Interface to the Macintosh Libraries
  5.  
  6.  
  7.     <<< ErrMgr - Error File Manager Routines Interface File >>> 
  8.     
  9.     
  10.     Copyright Apple Computer, Inc.    1987-1991
  11.     All rights reserved
  12.     
  13.     This file contains:
  14.     
  15.     InitErrMgr(toolname, sysename, Nbrs)  - ErrMgr initialization
  16.     CloseErrMgr()                          - Close ErrMgr message files
  17.     GetSysErrText(Nbr, Msg)               - Get a system error message for a number
  18.     GetToolErrText(Nbr, Insert, Msg)      - Get a tool error message for a number
  19.     AddErrInsert(insert, msgString)       - Add an insert to a message
  20.     
  21. }
  22.  
  23.  
  24. {$IFC UNDEFINED UsingIncludes}
  25. {$SETC UsingIncludes := 0}
  26. {$ENDC}
  27.  
  28. {$IFC NOT UsingIncludes}
  29.     UNIT ErrMgr;
  30.     INTERFACE
  31. {$ENDC}
  32.  
  33. {$IFC UNDEFINED UsingErrMgr}
  34. {$SETC UsingErrMgr := 1}
  35.  
  36. {$I+}
  37. {$SETC ErrMgrIncludes := UsingIncludes}
  38. {$SETC UsingIncludes := 1}
  39. {$IFC UNDEFINED UsingTypes}
  40. {$I $$Shell(PInterfaces)Types.p}
  41. {$ENDC}
  42. {$SETC UsingIncludes := ErrMgrIncludes}
  43.  
  44.  
  45. PROCEDURE InitErrMgr(toolErrFilename: Str255;sysErrFilename: Str255;showToolErrNbrs: BOOLEAN);
  46. { ErrMgr initialization.This must be done before using any other ErrMgr
  47. routine.  Set showToolErrNbrs to true if you want all tool messages to contain
  48. the error number following the message text enclosed in parentheses (e.g.,
  49. "<msg txt> ([OS] Error <n>)"; system error messages always contain the error
  50. number).  The toolErrFileName parameter is used to specify the name of a
  51. tool-specific error file, and should be the NULL or a null string if not used
  52. (or if the tool's data fork is to be used as the error file, see
  53. GetToolErrText for futher details). The sysErrFileName parameter is used to
  54. specify the name of a system error file, and should normally be the NULL or a
  55. null string, which causes the ErrMgr to look in the MPW Shell directory for
  56. "SysErrs.Err" (see GetSysErrText). }
  57.  
  58. PROCEDURE CloseErrMgr; C;
  59. { Ideally a CloseErrMgr should be done at the end of execution to make sure all
  60. files opened by the ErrMgr are closed.    You can let normal program termination
  61. do the closing.  But if you are a purist...
  62.  }
  63.  
  64. PROCEDURE GetSysErrText(msgNbr: INTEGER;errMsg: StringPtr);
  65. (* Get the error message text corresponding to system error number errNbr from
  66. the system error message file (whose name was specified in the InitErrMgr
  67. call).    The text of the message is returned in errMsg and the function returns
  68. a pointer to errMsg.  The maximum length of the message is limited to 254
  69. characters.
  70.  
  71. Note, if a system message filename was not specified to InitErrMgr, then the
  72. ErrMgr assumes the message file contained in the file "SysErrs.Err".  This
  73. file is first accessed as "                                 {ShellDirectory}SysErrs.Err" on the assumption that
  74. SysErrs.Err is kept in the same directory as the MPW Shell.  If the file
  75. cannot be opened, then an open is attempted on "SysErrs.Err" in the System
  76. Folder. *)
  77.  
  78. PROCEDURE AddErrInsert(insert: Str255;msgString: StringPtr); C;
  79. { Add another insert to an error message string.This call is used when more
  80. than one insert is to be added to a message (because it contains more than
  81. one '^' character).
  82.  }
  83.  
  84. PROCEDURE GetToolErrText(msgNbr: INTEGER;errInsert: Str255;errMsg: StringPtr);
  85. (* Get the error message text corresponding to tool error number errNbr from
  86. the tool error message file (whose name was specified in the InitErrMgr
  87. call).    The text of the message is returned in errMsg and the function returns
  88. a pointer to errMsg.  The maximum length of the message is limited to 254
  89. characters.  If the message is to have an insert, then ErrInsert should be a
  90. pointer to it.    Otherwise it should be either be a null string or a NULL
  91. pointer.
  92.  
  93. Inserts are indicated in error messages by specifying a '^' to indicate where
  94. the insert is to be placed.
  95.  
  96. Note, if a tool message filename was not specified to InitErrMgr, then the
  97. ErrMgr assumes the message file contained in the data fork of the tool calling
  98. the ErrMgr.  This name is contained in the Shell variable    {Command} and the
  99. value of that variable is used to open the error message file. *)
  100.  
  101.  
  102.  
  103. {$ENDC}    { UsingErrMgr }
  104.  
  105. {$IFC NOT UsingIncludes}
  106.     END.
  107. {$ENDC}
  108.  
  109.